package com.wg.springbootfilter;

import com.wg.springbootfilter.two.MyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.FilterRegistration;

/**
 * @Description:
 * @Author WuGang
 * @Date 2021/10/20 20:31
 * @Version 1.0
 */
@Configuration
public class FilterConfig {
    @Bean
    public FilterRegistrationBean  myFilterRegistrationBean(){
        FilterRegistrationBean<MyFilter> myFilterFilterRegistrationBean = new FilterRegistrationBean<>(new MyFilter());
//        ***注意过滤器的路径不能用两个**：/user/**
        myFilterFilterRegistrationBean.addUrlPatterns("/user/*");
        return myFilterFilterRegistrationBean;
    }
}
